package net.minecraft.client.renderer.texture;

import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.opengl.GL11;
import net.shadersmod.client.MultiTexID;
import net.shadersmod.client.ShadersTex;

public abstract class AbstractTexture implements ITextureObject {
	protected int glTextureId = -1;
	protected boolean blur;
	protected boolean mipmap;
	protected boolean blurLast;
	protected boolean mipmapLast;
	private static final String __OBFID = "CL_00001047";
	public MultiTexID multiTex;

	public void setBlurMipmapDirect(boolean p_174937_1_, boolean p_174937_2_) {
		this.blur = p_174937_1_;
		this.mipmap = p_174937_2_;
		boolean flag = true;
		boolean flag1 = true;
		int i;
		short short1;

		if (p_174937_1_) {
			i = p_174937_2_ ? 9987 : 9729;
			short1 = 9729;
		} else {
			i = p_174937_2_ ? 9986 : 9728;
			short1 = 9728;
		}

		GlStateManager.bindTexture(this.getGlTextureId());
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, short1);
	}

	public void setBlurMipmap(boolean p_174936_1_, boolean p_174936_2_) {
		this.blurLast = this.blur;
		this.mipmapLast = this.mipmap;
		this.setBlurMipmapDirect(p_174936_1_, p_174936_2_);
	}

	public void restoreLastBlurMipmap() {
		this.setBlurMipmapDirect(this.blurLast, this.mipmapLast);
	}

	public int getGlTextureId() {
		if (this.glTextureId == -1) {
			this.glTextureId = TextureUtil.glGenTextures();
		}

		return this.glTextureId;
	}

	public void deleteGlTexture() {
		ShadersTex.deleteTextures(this, this.glTextureId);

		if (this.glTextureId != -1) {
			TextureUtil.deleteTexture(this.glTextureId);
			this.glTextureId = -1;
		}
	}

	public MultiTexID getMultiTexID() {
		return ShadersTex.getMultiTexID(this);
	}
}
